package com.mashibing.juc.c_024_FromVectorToQueue;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedDeque;

/**
 * 多线程容器少考虑List
 * 多考虑Queue
 * @author: Yuanzt
 * @Date: 2021/4/1
 */
public class TicketSeller4 {

    static Queue<String> tickets = new ConcurrentLinkedDeque<>();
    static {
        for (int i = 0; i < 1000; i++) tickets.add("票号："+i);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            new Thread(()->{
                while (true){
                    String s = tickets.poll();
                    if (s == null) break;
                    else System.out.println("销售了--" + s);
                }
            }).start();
        }
    }

}
